package j.framework.qmd.core;

import java.io.Serializable;

/**
 * User: jason
 * Date: 14-7-18 上午11:10
 */
public class QueryFieldMetadata implements Serializable {

    public String getFieldKey(){
        if(usedFieldNameAsKey){
            return fieldName;
        }else{
            return fieldId;
        }
    }

    private String fieldId;

    private String queryId;

    private String tableAliasName;

    private String fieldName;

    private boolean usedFieldNameAsKey;//在输入数据到前端中，使用fieldName作为key，默认使用ID值

    private String displayName;//显示名称

    private String displayNameTag; //可用来显示多表头

    private Integer width;

    private DataType dataType;

    private boolean isPrimaryKey;

    private boolean isSuppressible;

    private boolean isSortSupported;//是否支持排序

    private DataAlign columnDataAlign;

    private DataAlign columnHeaderAlign;

    private String formatterMethodName;

    private String clientFormatter;

    private boolean isFooterSupported;

    private boolean footerCalcSupported;

    private int displayOrder;

    private boolean isDefaultSort;

    private String defaultSortOrder;

    private boolean isAsTreeField;

    private boolean isAsTreeParentField;

    private FormatType formatType;

    private String dictionaryId;

    private String formatOptions;

    public String getFieldId() {
        return fieldId;
    }
    public void setFieldId(String fieldId) {
        this.fieldId = fieldId;
    }

    public String getQueryId() {
        return queryId;
    }
    public void setQueryId(String queryId) {
        this.queryId = queryId;
    }

    public String getTableAliasName() {
        return tableAliasName;
    }
    public void setTableAliasName(String tableAliasName) {
        this.tableAliasName = tableAliasName;
    }

    public String getFieldName() {
        return fieldName;
    }
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public boolean isUsedFieldNameAsKey() {
        return usedFieldNameAsKey;
    }
    public void setUsedFieldNameAsKey(boolean usedFieldNameAsKey) {
        this.usedFieldNameAsKey = usedFieldNameAsKey;
    }

    public String getDisplayName() {
        return displayName;
    }
    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getDisplayNameTag() {
        return displayNameTag;
    }
    public void setDisplayNameTag(String displayNameTag) {
        this.displayNameTag = displayNameTag;
    }

    public Integer getWidth() {return width;}
    public void setWidth(Integer width) {
        this.width = width;
    }

    public DataType getDataType() {
        return dataType;
    }
    public void setDataType(DataType dataType) {
        this.dataType = dataType;
    }

    public boolean isPrimaryKey() {
        return isPrimaryKey;
    }
    public void setPrimaryKey(boolean isPrimaryKey) {
        this.isPrimaryKey = isPrimaryKey;
    }

    public boolean isSuppressible() {
        return isSuppressible;
    }
    public void setSuppressible(boolean isSuppressible) {
        this.isSuppressible = isSuppressible;
    }

    public boolean isSortSupported() {
        return isSortSupported;
    }
    public void setSortSupported(boolean isSortSupported) {
        this.isSortSupported = isSortSupported;
    }

    public DataAlign getColumnDataAlign() {
        return columnDataAlign;
    }
    public void setColumnDataAlign(DataAlign columnDataAlign) {
        this.columnDataAlign = columnDataAlign;
    }

    public DataAlign getColumnHeaderAlign() {
        return columnHeaderAlign;
    }
    public void setColumnHeaderAlign(DataAlign columnHeaderAlign) {
        this.columnHeaderAlign = columnHeaderAlign;
    }

    public String getFormatterMethodName() {
        return formatterMethodName;
    }
    public void setFormatterMethodName(String formatterMethodName) {
        this.formatterMethodName = formatterMethodName;
    }

    public String getClientFormatter() {
        return clientFormatter;
    }
    public void setClientFormatter(String clientFormatter) {
        this.clientFormatter = clientFormatter;
    }

    public boolean isFooterCalcSupported() {
        return footerCalcSupported;
    }
    public void setFooterCalcSupported(boolean footerCalcSupported) {
        this.footerCalcSupported = footerCalcSupported;
    }

    public boolean isFooterSupported() {
        return isFooterSupported;
    }
    public void setFooterSupported(boolean isFooterSupported) {
        this.isFooterSupported = isFooterSupported;
    }

    public int getDisplayOrder() {
        return displayOrder;
    }
    public void setDisplayOrder(int displayOrder) {
        this.displayOrder = displayOrder;
    }

    public boolean isDefaultSort() {
        return isDefaultSort;
    }
    public void setDefaultSort(boolean isDefaultSort) {
        this.isDefaultSort = isDefaultSort;
    }

    public String getDefaultSortOrder() {
        return defaultSortOrder;
    }
    public void setDefaultSortOrder(String defaultSortOrder) {
        this.defaultSortOrder = defaultSortOrder;
    }

    public boolean isAsTreeField() {
        return isAsTreeField;
    }
    public void setAsTreeField(boolean isAsTreeField) {
        this.isAsTreeField = isAsTreeField;
    }

    public boolean isAsTreeParentField() {
        return isAsTreeParentField;
    }
    public void setAsTreeParentField(boolean isAsTreeParentField) {
        this.isAsTreeParentField = isAsTreeParentField;
    }

    public FormatType getFormatType() {
        if(formatType == null){
            formatType = FormatType.NONE;
        }
        return formatType;
    }
    public void setFormatType(FormatType formatType) {
        this.formatType = formatType;
    }

    public String getDictionaryId() {
        return dictionaryId;
    }
    public void setDictionaryId(String dictionaryId) {
        this.dictionaryId = dictionaryId;
    }

    public String getFormatOptions() {
        return formatOptions;
    }
    public void setFormatOptions(String formatOptions) {
        this.formatOptions = formatOptions;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        QueryFieldMetadata that = (QueryFieldMetadata) o;

        if (fieldId != null ? !fieldId.equals(that.fieldId) : that.fieldId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return fieldId != null ? fieldId.hashCode() : 0;
    }
}
